<script setup>
import { ref, onMounted } from 'vue'
import HomePanel from './HomePanel.vue';

import { getHotAPI } from '@/apis/home'
const hotList = ref([]);
const getHot = async () => {
    const res = await getHotAPI();
    hotList.value = res.result;
}
onMounted(() => getHot())
</script>

<template>
    <HomePanel title="人气商品" sub-title="新鲜出炉 品质靠谱">
        <ul class="goods-list">
            <li v-for="item in hotList" :key="item.id">
                <RouterLink to="/">
                    <img v-img-lazy="item.picture" alt="" />
                    <p class="name">{{ item.name || '未知商品' }}</p>
                    <p class="price"></p>
                </RouterLink>
            </li>
        </ul>
    </HomePanel>
    <div></div>
</template>


<style scoped lang='scss'>
.goods-list {
    display: flex;
    // justify-content: space-between;
    // height: 406px;
    width: 1226px;

    li {
        width: 276px;
        // height: 406px;
        margin: 0 15px;

        background: #f0f9f4;
        transition: all 0.5s;

        &:hover {
            transform: translate3d(0, -3px, 0);
            box-shadow: 0 3px 8px #999;// x轴位移 y轴位移 模糊度 颜色
        }

        img {
            width: 100%;
            height: 276px;
        }

        p {
            font-size: 22px;
            padding-top: 12px;
            text-align: center;
            text-overflow: ellipsis;
            overflow: hidden;
            white-space: nowrap;
        }

        .price {
            color: $priceColor;
        }
    }
}
</style>